<%@page import="model.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	User u = new User();
	String action = null;
	String title = null;
	String nAction = null;
	String info = null;
	String value = null;
	SetUp setUp = new SetUp();
	String nid = ((String) request.getParameter("nid"));
	String mid = ((String) request.getParameter("mid"));
	String uid = ((String) request.getParameter("uid"));
	String cid = ((String) request.getParameter("cid"));
	String acid = ((String) request.getParameter("acid"));
	if (nid != null) {
		National national = new National();
		if (!national.isNID(nid)) {
			response.sendRedirect(setUp.getBASE_URL()
					+ "/a/message.jsp?m=errnid&r=vn");
		} else {
			nid.trim();
			action = "DelNational";
			title = "Delete National";
			national = national.getNational(Integer.parseInt(nid));
			nAction = national.getN_name();
			info = "nid";
			value = nid;
		}
	} else if (mid != null) {
		Message message = new Message();
		if (!message.isMID(mid)) {
			response.sendRedirect(setUp.getBASE_URL()
					+ "/a/message.jsp?m=err-mid&r=vm");
		} else {
			mid.trim();
			action = "DelMessage";
			title = "Delete Message";
			message = message.getMg(Integer.parseInt(mid));
			nAction = message.getM_name();
			info = "mid";
			value = mid;
		}
	}
	else if (cid != null) {
		Categories categories = new Categories();
		if (!categories.isCID(cid)) {
			response.sendRedirect(setUp.getBASE_URL()
					+ "/a/message.jsp?m=err-cid&r=vc");
		} else {
			cid.trim();
			action = "DelCat";
			title = "Delete Categories";
			categories = categories.getCatByID(Integer.parseInt(cid));
			nAction = categories.getCat_name();
			info = "cid";
			value = cid;
		}
	}
	
	else if (acid != null) {
		Actor actor = new Actor();
		if (!actor.isAcID(acid)) {
			response.sendRedirect(setUp.getBASE_URL()
					+ "/a/message.jsp?m=err-acid&r=vac");
		} else {
			acid.trim();
			action = "DelActor";
			title = "Delete Actor";
			actor = actor.getActor(Integer.parseInt(acid));
			nAction = actor.getAc_name();
			info = "acid";
			value = acid;
		}
	}
	else if (uid != null) {
		if (!u.isUID(uid)) {
			response.sendRedirect(setUp.getBASE_URL()
					+ "/a/message.jsp?m=err-uid&r=vu");
		} else {
			action = "DelUser";
			title = "Delete User";
			u = u.getUserByID(Integer.parseInt(uid));
			nAction = u.getUserName();
			info = "uid";
			value = uid;
		}

	}else {
		response.sendRedirect(setUp.getBASE_URL()
				+ "/a/message.jsp?m=err-dl&r=a");
	}
	//check User is not admin  redirect to index
	if (!u.isAdmin((String) session.getAttribute("lv"))) {
		response.sendRedirect(setUp.getBASE_URL() + "/index.jsp");
	} else {
		/*  uid = (String) session.getAttribute("uid"); */
	}
%>
<title>MYFILM - Delete</title>
<jsp:include page="../include/header.jsp"></jsp:include>
<jsp:include page="../include/slide-show.jsp"></jsp:include>
<div id="content-container">
	<jsp:include page="../include/sidebar-admin.jsp"></jsp:include>
	<div id="content">
		<h2><%=title%>
			:
			<%=nAction%></h2>
		<form action="<%=action%>" method="post">
			<fieldset>
				<legend><%=title%></legend>
				<label for="delete">Are you sure?</label>

				<div>
					<input type="radio" name="delete" value="no" checked="checked" />No
					<input type="radio" name="delete" value="yes" />Yes <input
						type="hidden" name="<%=info%>" value="<%=value%>" />
				</div>
				<div>
					<input type="submit" name="submit" value="Delete"
						onclick="return confirm('Are you sure?')" />
				</div>
			</fieldset>
		</form>
	</div>
</div>
<!--end content-->
<%--   <jsp:include page="../include/sidebar-b.jsp"></jsp:include> --%>
<jsp:include page="../include/footer.jsp"></jsp:include>